Function.prototype.myBind = function (context) {
  if (typeof this !== 'function') {
    throw new TypeError('Error')
  }
  var _this = this
  var args = [...arguments].slice(1)
  // 返回一个函数
  return function F() {
    // 因为返回了一个函数，我们可以 new F()，所以需要判断
    if (this instanceof F) {
      console.log('my console _this : ', _this);
      console.log('my console this : ', this);
      console.log('my console this : ', this instanceof Function);
      console.log('my console this : ', this instanceof Object);
      console.log('my console ...args : ', ...args);
      console.log('my console ...arguments : ', ...arguments);
      return new _this(...args, ...arguments)
    }
    console.log('my console ...arguments : ', ...arguments);
    return _this.apply(context, args.concat(...arguments))
  }
}

function test(arg) {
  console.log('my console test : ', this);
  console.log('my console arg : ', arg);
}

var bindObj = test.myBind()

var testObj = new bindObj(1)

console.log('my console testObj  : ', testObj instanceof test);